******************
**** Figure A4 ***
******************

use "$data/stickerpromptsurvey" , clear




** Data prep **
gen manipulation=0 if q1a==1 // People who see sticker for the first time vs saw sticker at home 
replace manipulation=1 if q1a==2

gen q2bALT=q2b
replace q2bALT=4 if identitylabel==0 & manipulation==0 // This corrects for the fact that people who saw a basic sticker at home cannot recall an identity label. 6549/9842 = 0,6645% received an Identity label

foreach var in q2a q2bALT q2c q2d {
gen bar`var'=0 if `var'!=.
replace bar`var'=1 if `var'<3 & `var'!=.
}

foreach var in q5a q5b q5c q5d q5e {
gen bar`var'=0 if `var'!=.
replace bar`var'=1 if `var'<2 & `var'!=.
}






* Acceptability of stickers ** P-values
tab barq2a manipulation, col chi
tab barq2bALT manipulation,col chi
tab barq2c manipulation,col chi
tab barq2d manipulation,col chi


* Graph*
collapse (mean) barq2a barq2bALT barq2c barq2d barq5a barq5b barq5c barq5d barq5e (sebinomial) sebarq2a=barq2a sebarq2bALT=barq2b sebarq2c=barq2c sebarq2d=barq2d sebarq5a=barq5a sebarq5b=barq5b sebarq5c=barq5c sebarq5d=barq5d sebarq5e=barq5e,  by(manipulation)

replace barq2b=barq2b/0.6645 /// corrects for the fact that untreated customers by fact cannot remember a sticker


foreach var of varlist barq2a barq2bALT barq2c barq2d barq5a barq5b barq5c barq5d barq5e {
gen lb`var'=`var'-se`var'
gen ub`var'=`var'+se`var'
}

gen t1=1 if barq2a!=.
gen t2=1 if barq2bALT!=.
gen t3=1 if barq2c!=.
gen t4=1 if barq2d!=.


gen manipulation2=manipulation+2.5 // this is for correct placement of graphs
gen manipulation3=manipulation+5
gen manipulation4=manipulation+7.5
gen manipulation5=manipulation+10





twoway (bar barq2a manipulation if t1==1, color(gs8) barwidth(0.9) bargap(4)) (rcap lbbarq2a ubbarq2a manipulation, lcolor(black))  ///
       (bar barq2bALT manipulation2 if t2==1, color(gs8) barwidth(0.9)) (rcap lbbarq2bALT ubbarq2bALT manipulation2, lcolor(black)) ///
       (bar barq2c manipulation3 if t3==1, color(gs8) barwidth(0.9)) (rcap lbbarq2c ubbarq2c manipulation3, lcolor(black)) ///
       (bar barq2d manipulation4 if t4==1, color(gs8) barwidth(0.9)) (rcap lbbarq2d ubbarq2d manipulation4, lcolor(black)) ///
	   , yla (0(0.1)0.9) xlabel(0.5 "24h" 3 "Identity Appeal" 5.5 "Please Pay" 8 "Reminder", noticks labsize(small)) ytitle("Fraction with perfect or good recall", size(msmall)) graphregion(color(white)) title("Recall of sticker content", color(black)) legend(row(1) order(1 "Untreated (not seen before)" 2 "Treated (seen at home)") ) ///
	  legend(row(1) order(1 "Untreated (never seen)" 3 "Treated (seen at home)") )
	   graph export "$filepath/output_logs/figure a4.pdf", replace



